
import { createApp } from "vue";
import App from "@/App.vue"  ;
import svgIcon from '@/components/svgIcon.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'virtual:svg-icons-register'
import './style/index.scss'
import router from '@/router/index.ts'
import 'element-plus/dist/index.css'
import pinia from '@/stores/index.ts'
import  useUserStore  from '@/stores/modules/user'

// 暗黑模式样式
import 'element-plus/theme-chalk/dark/css-vars.css'


const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 全局注册组件
app.component('svg-icon', svgIcon)

// 注册路由组件
app.use(router)

// 注册仓库组件
app.use(pinia)

const userButtons = useUserStore().userInfo.buttons

console.log(userButtons);



// 全局注册按钮禁用指令
app.directive('disabled', {
  mounted(el,binding) {
    
    if(userButtons.includes(binding.value)) {
      el.disabled = false
      el.classList.remove('is-disabled')
    } else {
      el.disabled = true
      el.classList.add('is-disabled')
    }
  }
})

app.mount("#app");
